package com.gcit.seniorWish.web.modular.api.controller;

import com.baomidou.mybatisplus.mapper.Condition;
import com.gcit.seniorWish.core.base.controller.BaseController;
import com.gcit.seniorWish.web.common.persistence.model.ExamineeScore;
import com.gcit.seniorWish.web.config.web.MsgProducer;
import com.gcit.seniorWish.web.modular.inputMidScore.service.IExamineeScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018-04-08.
 */
@Controller
@RequestMapping("/api")
public class APIController extends BaseController {

    @Autowired
    private IExamineeScoreService examineeScoreService ;

    @Autowired
    private MsgProducer producer;


    /**
     * 单生产者-多消费者
     */
    @PostMapping("/oneToMany")
    public void oneToMany() {
        for(int i=0;i<10;i++){
            producer.sendMsg("dafafa"+i);
        }
    }


    @RequestMapping(value = "/examineeScore",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> getInfo(@RequestParam(value = "examSiteNum") String examsitenum ,
                                      @RequestParam(value = "seatNum") String seatnum,
                                      @RequestParam("examCardNum") String examcardnum){
        Map<String,Object> map = new HashMap () ;

        List list = examineeScoreService.selectList(Condition.create().eq("exam_site_number", examsitenum).eq("seat_number", seatnum).eq("exam_card_number", examcardnum));
        if(list!=null && list.size()==1){
            ExamineeScore examineeScore = (ExamineeScore) list.get(0);
            map.put("政治:",examineeScore.getPolitics());
            map.put("姓名:",examineeScore.getStudentName());
            map.put("中考总成绩:",examineeScore.getSenoirTotalScore());
            map.put("所属中学:",examineeScore.getSenoirSchoolName());
            map.put("座位号:",examineeScore.getSeatNumber());
            map.put("加分类型:",examineeScore.getScorePlusName());
            map.put("加分分数:",examineeScore.getScorePlus());
            map.put("体育:",examineeScore.getSport());
            map.put("物理:",examineeScore.getPhysics());
            map.put("化学:",examineeScore.getChemistry());
            map.put("数学:",examineeScore.getMath());
            map.put("历史:",examineeScore.getHistory());
            map.put("性别:",examineeScore.getGender());
            map.put("考场号:",examineeScore.getExamSiteNumber());
            map.put("准考证号:",examineeScore.getExamCardNumber());
            map.put("英语:",examineeScore.getEnglish());
            map.put("语文:",examineeScore.getChinese());
            map.put("建档号:",examineeScore.getArchivesNumber());
            map.put("加分中分:",examineeScore.getTotalScore());

        }else {
            map.put("error","查询失败");
        }
        return  map ;
    }

}
